﻿@model Zor_Web.Models.Base.V_Zor_Hous
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>商铺信息列表</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>
    <!-- 表单验证 -->
    <script src="~/Content/Scripts/JValidator.js"></script>
</head>
<body class="gray-bg">
    <div class="layui-tab layui-tab-brief main-tab-container ">
        <div class="col-sm-12 ct-padding">
            <div class="col-sm-9 ct-padding">
                <button id="btnAdd" class="layui-btn layui-btn layui-btn-small"><span class="glyphicon glyphicon-plus"></span> 新增</button>
                <button id="btnUpdate" class="layui-btn layui-btn-warm layui-btn-small"><span class="glyphicon glyphicon-pencil"></span> 编辑</button>
                <button id="btnDelete" class="layui-btn layui-btn-danger layui-btn-small"><span class="glyphicon glyphicon-trash"></span> 删除</button>
                <button id="btnRent" class="layui-btn layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-jpy"></span> 租赁</button>                
                <button id="btnSearch" class="layui-btn layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span> 查询</button>                
                <button id="btnMessage" class="layui-btn layui-btn-orchid layui-btn-small"><span class="glyphicon glyphicon-list-alt"></span> 详情</button>
                <button id="btnExport" class="layui-btn layui-btn-springgreen  layui-btn-small"><span class="glyphicon glyphicon-share"></span> 导出</button>
                <button id="btnReplace" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-refresh"></span> 刷新</button>
            </div>
        </div>
        <div class="col-sm-12  layui-tab-content">
            <div class="mail-box" style="overflow-x:scroll;white-space:nowrap;">
                <table class="layui-table" lay-skin="line">
                    <thead>
                        <tr>
                            <th hidden></th>
                            <th></th>
                            <th>商铺编号</th>
                            <th>所属街道(楼宇)</th>
                            <th>所属门牌</th>
                            <th>业主姓名</th>
                            <th>业主性别</th>
                            <th>身份证号</th>
                            <th>联系电话</th>
                            <th>商铺用途</th>
                            <th>商铺面积(㎡)</th>
                            <th>地球经度</th>
                            <th>地球纬度</th>
                            <th hidden>纳税方式</th>
                            <th>创建日期</th>
                            <th>商铺属性</th>
                            <th>商铺产权</th>
                        </tr>
                    </thead>
                    <tbody id="accordion">

                        @foreach (var item in Model.PageData)
                        {
                            if (@item.Shop_Longitude == null && @item.Shop_Latitude == null)
                        {
                            <tr>
                                <td hidden>@item.Hs_Id</td>
                                <td><input type="radio" name="chk" id="@item.Hs_Id" value="@item.Hs_Id" /></td>
                                <td>@item.Hs_Number</td>
                                <td> <span class='label label-warning pull-center'>请将（@item.Bd_Name）信息补充完整</span></td> 
                                <td>@item.Uim_Name</td>
                                <td>@item.NatPer_Name</td>
                                <td>@item.NatSex</td>
                                <td>@item.NatPer_IDNumber</td>
                                <td>@item.NatPer_Phone</td>
                                <td>@item.HousUse</td>
                                <td>@item.Hs_Proportion</td>
                                <td>@item.Shop_Longitude</td>
                                <td>@item.Shop_Latitude</td>
                                <td hidden>@item.TaxeMode</td>
                                <td>@TimeHelper.TimeStampToDateTime(item.Hs_CreateTime.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                                <td hidden>@item.Bd_Id</td>
                                <td hidden>@item.Uf_Id</td>
                                <td hidden>@item.NatPer_Sex</td>
                                <td hidden>@item.Hs_HousUse</td>
                                <td hidden>@item.Shop_TaxeMode</td>
                                <td hidden>@item.NatPer_Id</td>
                                <td hidden>@item.Hs_attribute</td>
                                <td hidden>@item.Hs_Cqsx</td>
                                <td>@item.Attribute</td>
                                <td>@item.Cqsx</td>
                            </tr>
                        }
                            else {
                            <tr>
                                <td hidden>@item.Hs_Id</td>
                                <td><input type="radio" name="chk" id="@item.Hs_Id" value="@item.Hs_Id" /></td>
                                <td>@item.Hs_Number</td>
                                <td>@item.Bd_Name</td> 
                                <td>@item.Uim_Name</td>
                                <td>@item.NatPer_Name</td>
                                <td>@item.NatSex</td>
                                <td>@item.NatPer_IDNumber</td>
                                <td>@item.NatPer_Phone</td>
                                <td>@item.HousUse</td>
                                <td>@item.Hs_Proportion</td>
                                <td>@item.Shop_Longitude</td>
                                <td>@item.Shop_Latitude</td>
                                <td hidden>@item.TaxeMode</td>
                                <td>@TimeHelper.TimeStampToDateTime(item.Hs_CreateTime.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                                <td hidden>@item.Bd_Id</td>
                                <td hidden>@item.Uf_Id</td>
                                <td hidden>@item.NatPer_Sex</td>
                                <td hidden>@item.Hs_HousUse</td>
                                <td hidden>@item.Shop_TaxeMode</td>
                                <td hidden>@item.NatPer_Id</td>
                                <td hidden>@item.Hs_attribute</td>
                                <td hidden>@item.Hs_Cqsx</td>
                                <td>@item.Attribute</td>
                                <td>@item.Cqsx</td>
                            </tr>
                          }
                    }

                    </tbody>
                </table>
                <div class="col-sm-12">
                    <div class="col-sm-10">
                        @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "", @class = "pagination" })
                    </div>
                    <div class="col-sm-2 to-righjt">
                        共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 新增修改模态 -->
    <div id="myModal" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <form class="form-horizontal m-t">
                <div class="layui-form-item" hidden>
                    <label class="col-sm-4 layui-form-label">ID：</label>
                    <div class="col-sm-8">
                        <input id="Hs_Id" type="text" class="form-control">
                    </div>
                </div>
                <div class="layui-form-item" hidden>
                    <label class="col-sm-4 layui-form-label">NatPer_Id：</label>
                    <div class="col-sm-8">
                        <input id="NatPer_Id" type="text" class="form-control">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">商铺编号：</label>
                    <div class="col-sm-4">
                        <input id="Hs_Number" type="text" class="form-control" autofocus="autofocus" datacol="yes" err="商铺编号" checkexpession="NotNull">
                    </div>
                    <label class="col-sm-2 layui-form-label">业主姓名：</label>
                    <div class="col-sm-4">
                        <input id="NatPer_Name" type="text" class="form-control" autofocus="autofocus" datacol="yes" err="业主姓名" checkexpession="ChineseStrOrNull">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">所属街道(楼宇)：</label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Bd_Id"></select>
                    </div>
                    <label class="col-sm-2 layui-form-label">身份证号：</label>
                    <div class="col-sm-4">
                        <input id="NatPer_IDNumber" type="text" class="form-control" autofocus="autofocus" datacol="yes" err="身份证号" checkexpession="IDCard">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>

                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">所属门牌：</label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Uf_Id"></select>
                    </div>

                    <label class="col-sm-2 layui-form-label">联系电话：</label>
                    <div class="col-sm-4">
                        <input id="NatPer_Phone" type="text" class="form-control" autofocus="autofocus" datacol="yes" err="联系电话" checkexpession="MobileOrPhone">
                    </div>
                </div>

                <div class="hr-line-dashed"></div>
                <div class="layui-form-item">

                
                    <label class="col-sm-2 layui-form-label">商铺用途：</label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Hs_HousUse">
                            <option value="1">-请选择-</option>
                            <option value="3">租赁</option>
                            <option value="2">自住</option>
                            <option value="1">闲置空房</option>
                        </select>
                    </div>
                    <label class="col-sm-2 layui-form-label">业主性别：</label>
                    <div class="col-sm-4">
                        <input type="radio" value="1" id="NatPer_Sex_yes" name="sex" checked>男
                        &nbsp;&nbsp;&nbsp;
                        <input type="radio" value="2" id="NatPer_Sex_no" name="sex">女
                    </div>
                </div>
          
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">商铺属性：</label>
                    <div class="col-sm-4">
                        <select name="temp" class="form-control" id="Hs_attribute">
                            <option value="1">-请选择-</option>
                            <option value="1">住宅</option>
                            <option value="2">非住宅</option>
                        </select>
                    </div>
                        <label class="col-sm-2 layui-form-label">商铺产权：</label>
                        <div class="col-sm-4">
                            <select name="temp" class="form-control" id="Hs_Cqsx" disabled="">
                                <option value="1">个人</option>
                                <option value="2">非个人</option>
                            </select>
                        </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">经度：</label>
                    <div class="col-sm-4">
                        <div class="input-group">
                            <input id="Shop_Longitude" type="text" class="form-control" autofocus="autofocus" />
                            <div class="input-group-btn">
                                <button id="Butjingdu" class="btn btn-info" type="button">
                                    选择
                                </button>
                            </div>
                        </div>
                    </div>
                    <label class="col-sm-2 layui-form-label">纬度：</label>
                    <div class="col-sm-4">
                        <div class="input-group">
                            <input id="Shop_Latitude" type="text" class="form-control" autofocus="autofocus" />
                            <div class="input-group-btn">
                                <button id="Butweidu" class="btn btn-info" type="button">
                                    选择
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">商铺面积(㎡)：</label>
                        <div class="col-sm-4">
                            <input id="Hs_Proportion" type="text" class="form-control" autofocus="autofocus" datacol="yes" err="商铺面积" checkexpession="NotNull">
                        </div>
                        <label hidden class="col-sm-2 layui-form-label">纳税方式：</label>
                        <div hidden class="col-sm-4">
                            <select name="temp" class="form-control" id="Shop_TaxeMode">
                                <option value="1">-请选择-</option>
                                <option value="-1">无</option>
                                <option value="1">正常纳税</option>
                                <option value="2">零散纳税</option>
                            </select>
                        </div>
                    </div>
        </form>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-sm-11 ">
                <button id="btnSure" class="btn btn-info pull-right">
                    <i class="fa fa-check"></i>提交
                </button>
            </div>
        </div>
    </div>

    @using (Html.BeginForm("Zor_Shops", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
    {
    <!-- 查询模态框 -->
        <div id="myModalSearch" hidden data-backdrop="static">
            <div id="divselectfrom" class="layui-tab-content">
                <form class="form-horizontal m-t">
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">商铺编号：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="Hs_Number" value="@Model.Hs_Number">
                        </div>
                        <label class="col-sm-2 layui-form-label">所属街道(楼宇)：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="Bd_Name" value="@Model.Bd_Name">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">所属门牌：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="Uim_Name" value="@Model.Uim_Name">
                        </div>
                        <label class="col-sm-2 layui-form-label">业主姓名：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="NatPer_Name" value="@Model.NatPer_Name">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">身份证号：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="NatPer_IDNumber" value="@Model.NatPer_IDNumber">
                        </div>
                        <label class="col-sm-2 layui-form-label">联系电话：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="NatPer_Phone" value="@Model.NatPer_Phone">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">商铺面积：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="Hs_Proportion" value="@Model.Hs_Proportion">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">商铺属性：</label>
                        <div class="col-sm-4">
                            <select class="form-control" name="Hs_attribute">
                                <option value="@Model.Hs_attribute">-请选择-</option>
                                <option value="@Model.Hs_attribute">无</option>
                                <option value="@Model.Hs_attribute">住宅</option>
                                <option value="@Model.Hs_attribute">非住宅</option>
                            </select>
                        </div>
                    </div>
                </form>
                <div class="box-footer">
                    <button type="submit" class="btn btn-info pull-right">
                        <i class="fa fa-search"></i>查询
                    </button>
                </div>
            </div>
        </div>
    }


    <!-- 租赁模态 -->
    <div id="myModalLease" hidden data-backdrop="static">
        <div id="divLeasefrom" class="layui-tab-content">
            <form class="form-horizontal m-t">
                <div class="layui-form-item" hidden>
                    <label class="col-sm-4 layui-form-label">ID：</label>
                    <div class="col-sm-8">
                        <input id="HouseShopId" type="text" class="form-control">
                    </div>
                    <label class="col-sm-4 layui-form-label">商铺编号：</label>
                    <div class="col-sm-8">
                        <input readonly id="Hs_Num" type="text" class="form-control">
                    </div>
                </div>

                <div class="hr-line-dashed"></div>
                <div class="layui-form-item">
                    <label class="col-sm-4 layui-form-label">租户：</label>
                    <div class="col-sm-8">
                        <select name="temp" class="form-control" id="Tenant_Id"></select>
                    </div>


                </div>
                <div class="layui-form-item">
                    <label class="col-sm-4 layui-form-label">租金：</label>
                    <div class="col-sm-8">
                        <input id="Lease_Rent" type="text" class="form-control" autofocus="autofocus">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-4 layui-form-label">租赁开始日期：</label>
                    <div class="col-sm-8">
                        <input id="Lease_StartTime" class="laydate-icon form-control layer-date" autofocus="autofocus">
                    </div>

                </div>
                <div class="layui-form-item">
                    <label class="col-sm-4 layui-form-label">租赁结束日期：</label>
                    <div class="col-sm-8">
                        <input id="Lease_EndTime" class="laydate-icon form-control layer-date" autofocus="autofocus">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="layui-form-item">
                    <label class="col-sm-4 layui-form-label">备注：</label>
                    <div class="col-sm-8">
                        <input id="Lease_Remarks" type="text" class="form-control" autofocus="autofocus">
                    </div>
                </div>

            </form>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-sm-11 ">
                <button id="btnRentSure" class="btn btn-info pull-right">
                    <i class="fa fa-check"></i>提交
                </button>
            </div>
        </div>
    </div>

    <!-- 详情模态 -->
    <div id="myModalMessage" hidden data-backdrop="static">
        <div id="divfrom1" class="ibox float-e-margins">
            <div class="modal-body">
                <form class="form-horizontal m-t">

                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">商铺编号：</label>
                        <div class="col-sm-4 layui-input" id="Hs_Number1">
                        </div>
                        <label class="col-sm-2 layui-form-label">所属街道(楼宇)：</label>
                        <div class="col-sm-4 layui-input" id="Bd_Name1">
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="layui-form-item">

                        <label class="col-sm-2 layui-form-label">所属门牌：</label>
                        <div class="col-sm-4 layui-input" id="Uim_Name1">
                        </div>

                        <label class="col-sm-2 layui-form-label">业主姓名：</label>
                        <div class="col-sm-4 layui-input" id="NatPer_Name1">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">身份证号：</label>
                        <div class="col-sm-4 layui-input" id="NatPer_IDNumber1">
                        </div>
                        <label class="col-sm-2 layui-form-label">联系电话：</label>
                        <div class="col-sm-4 layui-input" id="NatPer_Phone1">
                        </div>
                    </div>
                </form>
                <form class="form-horizontal m-t">
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">业主性别：</label>
                        <div class="col-sm-4 layui-input" id="NatSex1">
                        </div>
                        <label class="col-sm-2 layui-form-label">商铺用途：</label>
                        <div class="col-sm-4 layui-input" id="HousUse1">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">商铺属性：</label>
                        <div class="col-sm-4 layui-input" id="Hs_attribute1">
                        </div>
                        <label class="col-sm-2 layui-form-label">商铺产权：</label>
                        <div class="col-sm-4 layui-input" id="Hs_Cqsx1">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">地球经度：</label>
                        <div class="col-sm-4 layui-input" id="Shop_Longitude1">
                        </div>
                        <label class="col-sm-2 layui-form-label">地球纬度：</label>
                        <div class="col-sm-4 layui-input" id="Shop_Latitude1">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-2 layui-form-label">商铺面积：</label>
                        <div class="col-sm-4 layui-input" id="Hs_Proportion1">
                        </div>
                    </div>
              
                </form>
            </div>
        </div>
    </div>
        <!-- 导出模态 -->
        <form action="/Base/ExportShops" enctype="multipart/form-data" method="post" id="formDownload">
            <div id="exportHtml" style="display:none;">
                <div class="eh_wrap">
                    <div class="eh_head">
                        <p style="">请选择您要导出的数据列</p>
                    </div>
                    <table width="100%" cellpadding="5" cellspacing="0">
                        <tr>
                            <td><input id="Hs_Number" type="checkbox" value="商铺编号" name="chk_list" checked="checked" /><label>商铺编号</label></td>
                            <td><input id="Bd_Name" type="checkbox" value="所属街道(楼宇)" name="chk_list" checked="checked" /><label>所属街道</label></td>
                            <td><input id="Uim_Name" type="checkbox" value="所属门牌" name="chk_list" checked="checked" /><label>所属门牌</label></td>
                            <td><input id="NatPer_Name" type="checkbox" value="业主名称" name="chk_list" checked="checked" /><label>业主名称</label></td>
                        </tr>
                        <tr>

                            <td><input id="NatPer_IDNumber" type="checkbox" value="业主身份证号" name="chk_list" checked="checked" /><label>业主身份证号</label></td>
                            <td><input id="NatPer_Phone" type="checkbox" value="业主电话" name="chk_list" checked="checked" /><label>业主电话</label></td>
                            <td><input id="NatSex" type="checkbox" value="业主性别" name="chk_list" checked="checked" /><label>业主性别</label></td>
                            <td><input id="HousUse" type="checkbox" value="商铺用途" name="chk_list" checked="checked" /><label>商铺用途</label></td>
                        </tr>
                        <tr>
                            <td><input id="Hs_Proportion" type="checkbox" value="商铺面积" name="chk_list" checked="checked" /><label>商铺面积</label></td>
                            <td><input id="Shop_Longitude" type="checkbox" value="地球经度" name="chk_list" checked="checked" /><label>地球经度</label></td>
                            <td><input id="Shop_Latitude" type="checkbox" value="地球纬度" name="chk_list" checked="checked" /><label>地球纬度</label></td>
                            <td><input id="Hs_CreateTime" type="checkbox" value="创建时间" name="chk_list" checked="checked" /><label>创建时间</label></td>
                        </tr>
                        <tr>
                            <td><input id="attribute" type="checkbox" value="商铺属性" name="chk_list" checked="checked" /><label>商铺属性</label></td>
                            <td><input id="Cqsx" type="checkbox" value="商铺产权" name="chk_list" checked="checked" /><label>商铺产权</label></td>
                        </tr>
                    </table>
                    <div class="box-footer">
                        <button type="submit" id="btnExportSure" class="btn btn-info pull-right">
                            <i class="fa fa-repeat"></i>导出
                        </button>
                        <input type="hidden" id="HousingMeg" name="HousingMeg" value="" />
                        <input type="hidden" id="where" name="where" value="" />
                    </div>
                </div>
            </div>
        </form>

        <script>


            /**
          *   日期选择器
          */
            laydate.skin('molv');         //日历皮肤
            var start = {                   //开始时间选择
                elem: "#Lease_StartTime",
                format: "YYYY/MM/DD",
                min: '1900-01-01',
                max: "2099-06-16",
                istime: false,
                istoday: true,
                choose: function (datas) {
                    end.min = datas;
                    end.start = datas
                }
            };
            var end = {                     //结束时间选择
                elem: "#Lease_EndTime",
                format: "YYYY/MM/DD",
                min: '1900-01-01',
                max: "2099-06-16",
                istime: false,
                istoday: true,
                choose: function (datas) { start.max = datas }
            };
            laydate(start);
            laydate(end);

            //获取选中的性别
            function SaveAdmin() {
                var radio = $('input[name = "sex"]').filter(':checked');
                radio.attr("ID", "NatPer_Sex");
            }


            /**
           * 商铺详情
           */
            $(function () {
                $("#btnMessage").click(function () {
                    var checkId = CheckboxValueIDs();
                    var Hs_Number1 = getTableCell(2);
                    var Bd_Name1 = getTableCell(3);
                    var Uim_Name1 = getTableCell(4);
                    var NatPer_Name1 = getTableCell(5);
                    var NatPer_IDNumber1 = getTableCell(7);
                    var NatPer_Phone1 = getTableCell(8);
                    var NatSex1 = getTableCell(6);
                    var HousUse1 = getTableCell(9);
                    var Hs_Proportion1 = getTableCell(10);
                    var Shop_Longitude1 = getTableCell(11);
                    var Shop_Latitude1 = getTableCell(12);
                    var TaxeMode1 = getTableCell(13);
                    var Hs_attribute1 = getTableCell(23);
                    var Hs_Cqsx1 = getTableCell(24);

                    $("#lbltitle").text("修改商铺");
                    $("#Hs_Id").attr("disabled", "disabled");
                    if (checkId.length == 0) {
                        layer.msg("请选择要查看的商铺！");
                        $("#myModalMessage").attr("ID", "test");
                        return;
                    }
                    if (checkId.length > 1) {
                        layer.msg("仅可选择一栋商铺查看！");
                        $("#myModalMessage").attr("ID", "test");
                        return;
                    }
                    $("#test").attr("ID", "myModalMessage");
                    $("#Hs_Id").html(checkId[0]);
                    $("#Hs_Number1").html(Hs_Number1);
                    $("#Bd_Name1").html(Bd_Name1);
                    $("#Uim_Name1").html(Uim_Name1);
                    $("#NatPer_Name1").html(NatPer_Name1);
                    $("#NatPer_IDNumber1").html(NatPer_IDNumber1);
                    $("#NatPer_Phone1").html(NatPer_Phone1);
                    $("#NatSex1").html(NatSex1);
                    $("#HousUse1").html(HousUse1);
                    $("#Hs_Proportion1").html(Hs_Proportion1);
                    $("#Shop_Longitude1").html(Shop_Longitude1);
                    $("#Shop_Latitude1").html(Shop_Latitude1);
                    $("#TaxeMode1").html(TaxeMode1);
                    $("#Hs_attribute1").html(Hs_attribute1);
                    $("#Hs_Cqsx1").html(Hs_Cqsx1);
                    LayerOpen('800px', '388px', '商铺详情', $('#myModalMessage'));
                })
            })


            /**
            * 获取所属街道
            */
            function SelectBdName() {
                var html = "";
                getAjax("/Base/SelectBdName", "", function (data) {
                    accordionJson = eval("(" + data + ")");
                    html += "<option value='0' >-请选择-</option>";
                    $.each(accordionJson, function (i) {
                        html += "<option value='" + accordionJson[i].Bd_Id + "' >" + accordionJson[i].Bd_Name + "</option>";//初始化街道
                    });
                });
                $("#Bd_Id").empty().append(html);
                GetUimName($("#Bd_Id").val());//初始化
                /*注册街道下拉框事件 */
                $('#Bd_Id').change(function () {
                    GetUimName($(this).val());
                });
            }


            /**
             * 获取所属门牌
             */
            function GetUimName(sid) {
                var html = "";
                getAjax("/Base/GetUimName", { "id": sid }, function (data) {
                    accordionJson = eval("(" + data + ")");
                    html += "<option value='0' >-请选择-</option>";
                    $.each(accordionJson, function (i) {
                        html += "<option value='" + accordionJson[i].Uim_Id + "' >" + accordionJson[i].Uim_Name + "</option>";

                    });
                });
                $("#Uf_Id").empty().append(html);
            }
            /**
           * 查询商铺
           */
            $(function () {
                $("#btnSearch").click(function () {
                    ClearWebControls(divfrom);
                    LayerOpen('800px', '345px', '商铺查询', $('#myModalSearch'));
                })
            })
            /**
             * 选择经纬度
              */
            $(function () {
                $("#Butjingdu").click(function () {
                    OpenWindow("/Base/SearchMapShop", "", 700, 500);
                })
            })
            /**
            * 选择经纬度
            */
            $(function () {
                $("#Butweidu").click(function () {
                    OpenWindow("/Base/SearchMapShop", "", 700, 500);
                })
            })

            /**
          * 查询所有租户
          */
            function GetTenant() {
                var html = "";
                getAjax("/Base/GetTenant", "", function (data) {
                    accordionJson = eval("(" + data + ")");
                    html += "<option value='0' >-请选择-</option>";
                    $.each(accordionJson, function (i) {
                        html += "<option value='" + accordionJson[i].Tenant_Id + "' >" + accordionJson[i].Tenant_Name + "</option>";
                    });
                });
                $("#Tenant_Id").empty().append(html);
            }
            //租赁按钮
            $(function () {
                $("#btnRent").click(function () {
                 
                    var checkId = CheckboxValueIDs();
                    var Hs_Number = getTableCell(2);
                    if (checkId.length == 0) {
                        layer.msg("请选择要租赁的商铺！");
                        return;
                    }
                    if (checkId.length > 1) {
                        layer.msg("仅可选择一套商铺进行租赁！");
                        return;
                    }
                    var Hs_HousUse = getTableCell(18);
                    if (Hs_HousUse ==3)
                    {
                        GetTenant();
                        $("#HouseShopId").val(checkId[0]);
                        $("#Hs_Num").val(Hs_Number);
                        LayerOpen('500px', '335px', '房屋租赁', $('#myModalLease'));
                    }else
                    {
                        layer.msg("请选择用途为租赁的商铺！");
                    }
                  
                })
            })
            /**
          * 保存租赁信息
          */

            $(function () {
                $("#btnRentSure").click(function () {
                    var value = $('#Tenant_Id').val();
                    if (value == '0') {
                        layer.msg("请选择租户！");
                        return;
                    }                   
                    if ($("#Lease_Rent").val() == "") {
                        layer.msg("请输入租金！");
                        return;
                    }
                   
                    if ($("#Lease_StartTime").val() == "") {
                        layer.msg("租赁开始日期不能为空！");
                        return;
                    }
                    if ($("#Lease_EndTime").val() == "") {
                        layer.msg("租赁结束日期不能为空！");
                        return;
                    }
                    if ($("#Lease_Rent").val() != "") {
                        if (!$("#Lease_Rent").val().match(/^[0-9]+([.]{1}[0-9]+){0,1}$/)) {
                            layer.msg("请输入正确的租金!");
                            return;
                        }

                    }
                    var JsData = GetWebControls(divLeasefrom);
                    var Lease_StartTime = $("#Lease_StartTime").val();
                    var Lease_EndTime = $("#Lease_EndTime").val();
                    ZorPostSimpleData("/Base/AddHsLease", JSON.stringify({ "lease": JsData, "startTime": Lease_StartTime, "endTime": Lease_EndTime }), function (data) {
                        layer.msg(data.AnswerMeg, function () {
                            layer.closeAll();
                            Replace();
                        });
                    });
                })
            })
            /**
            * 增加商铺
            */
            $(function () {
                $("#btnAdd").click(function () {
                    ClearWebControls(divfrom);
                    SelectBdName();
                    LayerOpen('800px', '430px', '商铺新增', $('#myModal'));
                })
            })

            /**
            * 修改商铺
            */
            $(function () {
                $("#btnUpdate").click(function () {

                    var checkId = CheckboxValueIDs();
                    var Hs_Number = getTableCell(2);
                    var Bd_Id = getTableCell(15);
                    var Uf_Id = getTableCell(16);
                    var NatPer_Name = getTableCell(5);
                    var NatPer_IDNumber = getTableCell(7);
                    var NatPer_Phone = getTableCell(8);
                    var NatPer_Sex = getTableCell(17);
                    var Hs_HousUse = getTableCell(18);
                    var Hs_Proportion = getTableCell(10);
                    var Shop_Longitude = getTableCell(11);
                    var Shop_Latitude = getTableCell(12);
                    var Shop_TaxeMode = getTableCell(19);
                    var NatPer_Id = getTableCell(20);
                    var Hs_attribute = getTableCell(21);
                    var Hs_Cqsx = getTableCell(22);
                    $("#lbltitle").text("修改房屋");
                    $("#Hs_Id").attr("disabled", "disabled");
                    if (checkId.length == 0) {
                        layer.msg("请选择要修改的房屋！");
                        return;
                    }
                    if (checkId.length > 1) {
                        layer.msg("仅可选择一行信息修改！");
                        return;
                    }

                    SelectBdName();
                    GetUimName(Bd_Id)
                    $("#Hs_Id").val(checkId[0]);
                    $("#Hs_Number").val(Hs_Number);
                    $("#Bd_Id").val(Bd_Id);
                    $("#Uf_Id").val(Uf_Id);
                    $("#NatPer_Name").val(NatPer_Name);
                    $("#NatPer_IDNumber").val(NatPer_IDNumber);
                    $("#NatPer_Phone").val(NatPer_Phone);
                    $("#NatPer_Sex").val(NatPer_Sex);
                    $("#Hs_HousUse").val(Hs_HousUse);
                    $("#Hs_Proportion").val(Hs_Proportion);
                    $("#Shop_Longitude").val(Shop_Longitude);
                    $("#Shop_Latitude").val(Shop_Latitude);
                    $("#Shop_TaxeMode").val(Shop_TaxeMode);
                    $("#NatPer_Id").val(NatPer_Id);
                    $("#Hs_attribute").val(Hs_attribute);
                    $("#Hs_Cqsx").val(Hs_Cqsx);
                    LayerOpen('800px', '430px', '商铺修改', $('#myModal'));
                })
            })

            /**
            * 删除菜单
            */
            $(function () {
                $("#btnDelete").click(function () {
                    var checkId = CheckboxValueIDs();
                    if (checkId.length == 0) {
                        layer.msg("请选择要删除的商铺！");                                                             //未选中任何行
                        return;
                    }
                    else {
                        layer.confirm("确定要删除吗?", { icon: 2, btn: ['确定', '取消'] }, function () {
                            ZorPostSimpleData("/Base/DeleteShops", JSON.stringify({ 'id': checkId }), function (data) { //获取数据(带参数)
                                layer.msg(data.AnswerMeg, function () {
                                    layer.closeAll();
                                    Replace();
                                });
                            })
                        })
                    }
                })
            })

            /**
            * 刷新
            **/
            $(function () {
                $("#btnReplace").click(function () {
                    Replace();
                })
            })

            /**
            * 保存
            */
            $(function () {
                $("#btnSure").click(function () {
                    SaveAdmin();
                    if (!CheckDataValid('.form-horizontal')) {
                        return false;
                    }
                    if ($("#Shop_Longitude").val() <= 0) {
                        layer.msg("经度必须大于0！");
                        return;
                    }
                    if ($("#Shop_Latitude").val() <= 0) {
                        layer.msg("纬度必须大于0！");
                        return;
                    }
                    var JsData = GetWebControls(divfrom);
                    ZorPostSimpleData("/Base/AddShops", JSON.stringify({ "housing": JsData, "naturalPerson": JsData }), function (data) {
                        layer.msg(data.AnswerMeg, function () {
                            layer.closeAll();
                            Replace();
                        });
                    });
                })
            })
            /**
            * 模态关闭后回调用
            */
            $(function () {
                $('#myModal').on('hidden.bs.modal', function (e) {
                    Replace();
                })
                $('#myModalLease').on('hidden.bs.modal', function (e) {
                    Replace();
                })
            })

            /**
            * 全选
            */
            $(function () {
                $("#cbkCheckAll").click(function () {
                    if (this.checked) {
                        $("input[name='chk']").prop('checked', true);
                    } else {
                        $("input[name='chk']").prop('checked', false);
                    }
                })
            })
            /*导出*/
            $("#btnExport").click(function () {
                layer.open({
                    type: 1,
                    title: '导出提示',
                    shade: false,
                    skin: 'layui-layer-rim',
                    area: ['620px', '285px'], //宽高
                    content: $('#exportHtml')
                });
            });
            /*导出交互*/
            $("#btnExportSure").click(function () {
                var arr = new Array();
                $("[name='chk_list']").each(function () {
                    if ($(this).is(":checked")) {
                        arr.push($(this).attr("id") + "|" + $(this).val());
                    }
                });
                $("#HousingMeg").val(arr);
                document.getElementById('formDownload').submit();
                layer.closeAll();
            });
        </script>
</body>

</html>



